package instalador;

import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;

/**
 *
 * @author  acactown
 */
public class VentanaInstalador extends javax.swing.JFrame {

    private String rutaCliente;
    private String rutaServidor;
    private boolean termino;

    /** Creates new form ventana */
    public VentanaInstalador() {
        try {
            if (System.getProperty("file.separator").equals("/")) {
                VariablesDeEntorno.PLATAFORMA = "UNIX";
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } else {
                VariablesDeEntorno.PLATAFORMA = "WINDOWS";
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            }
        } catch (Exception ex) {
            System.out.println("No fue posible aplicar el LookAndFeel.");
        }
        initComponents();
        setTitle("Instalador - " + VariablesDeEntorno.NOMBREAPP);
        cambiarPanel();
        rutaCliente = System.getProperty("user.home") + VariablesDeEntorno.SEPARADOR + "TuLunch" + VariablesDeEntorno.SEPARADOR + "Cliente";
        rutaServidor = System.getProperty("user.home") + VariablesDeEntorno.SEPARADOR + "TuLunch" + VariablesDeEntorno.SEPARADOR + "Servidor";
        termino = false;
    }

    private void cerrar() {
        int cancelar = JOptionPane.showConfirmDialog(this, "¿ Realmente desea Cancelar la Instalacion ?", "Cancelar la Instalacion", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (cancelar == 0) {
            System.exit(0);
        }
    }

    @Override
    protected void processWindowEvent(WindowEvent e) {
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
            if (!termino) {
                cerrar();
            } else {
                System.exit(0);
            }
        }
    }

    private JPanel seleccionarPanel() {
        if (VariablesDeEntorno.PASOACTUAL == 1) {
            jButtonAnterior.setEnabled(false);
        } else {
            jButtonAnterior.setEnabled(true);
        }
        switch (VariablesDeEntorno.PASOACTUAL) {
            case 1:
                return paso1;
            case 2:
                return paso2;
            case 3:
                if (VariablesDeEntorno.TIPOINSTALACION.equals("CLIENTE")) {
                    if (jTextFieldIPServidor.getText().isEmpty() || jTextFieldSocket.getText().isEmpty()) {
                        jButtonSiguiente.setEnabled(false);
                    } else {
                        jButtonSiguiente.setEnabled(true);
                    }
                    return paso3C;
                } else {
                    continuarServidor();
                    return paso3S;
                }
            case 4:
                if (VariablesDeEntorno.TIPOINSTALACION.equals("CLIENTE")) {
                    jTextFieldRuta.setText(rutaCliente);
                } else {
                    jTextFieldRuta.setText(rutaServidor);
                }
                return paso4;
            case 5:
                VariablesDeEntorno.RUTA = jTextFieldRuta.getText();
                return paso5;
        }
        jButtonAnterior.setEnabled(false);
        jButtonCancelar.setText("Salir");
        jButtonCancelar.setEnabled(true);
        jButtonSiguiente.setEnabled(false);
        return pasoFinal;
    }

    private void cambiarPanel() {
        marco.removeAll();
        marco.updateUI();
        GroupLayout marcoLayout = new GroupLayout(marco);
        marco.setLayout(marcoLayout);
        marcoLayout.setHorizontalGroup(marcoLayout.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(seleccionarPanel(), 0, 586, Short.MAX_VALUE));
        marcoLayout.setVerticalGroup(marcoLayout.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(seleccionarPanel(), 0, 387, Short.MAX_VALUE));
        marco.updateUI();
        if (VariablesDeEntorno.PASOACTUAL == 5) {

            if (VariablesDeEntorno.TIPOINSTALACION.equals("SERVIDOR")) {
                if (VariablesDeEntorno.CONEXION.testConnection()) {
                    Datos crear = new Datos(this);
                    Thread hilo = new Thread(crear);
                    hilo.start();
                    termino = true;
                } else {
                    JOptionPane.showMessageDialog(this, "Por favor Verifique los Datos Suministrados\n Para la Conexion con el Servidor MySQL", "ERROR de Conexion con MySQL", JOptionPane.ERROR_MESSAGE);
                    VariablesDeEntorno.PASOACTUAL--;
                    jButtonAnteriorActionPerformed(null);
                }
            } else {
                Extractor extractor = new Extractor(this);
                Thread hilo = new Thread(extractor);
                hilo.start();
                termino = true;
            }
            if (termino) {
                jButtonAnterior.setEnabled(false);
                jButtonCancelar.setEnabled(false);
            }
        }
    }

    private void continuarServidor() {
        if (jTextFieldSocket2.getText().isEmpty() || jTextFieldUsuario.getText().isEmpty() || VariablesDeEntorno.PASSWORD.isEmpty() || jTextFieldHost.getText().isEmpty() || jTextFieldHost.getText().isEmpty() || jTextFieldPuerto.getText().isEmpty()) {
            jButtonSiguiente.setEnabled(false);
            jButtonTest.setEnabled(false);
            jLabelTest.setIcon(new ImageIcon());
        } else {
            jButtonSiguiente.setEnabled(true);
            jButtonTest.setEnabled(true);
        }

    }

    private File getDirectorioSalida(String directorioInicial) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setCurrentDirectory(new File(directorioInicial));
        fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
        fileChooser.setDialogTitle("Seleccione el directorio de destino para extraer el arhivo");
        fileChooser.setMultiSelectionEnabled(false);
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        if (fileChooser.showDialog(VentanaInstalador.this, "Seleccionar") != JFileChooser.APPROVE_OPTION) {
            return null;
        }
        return fileChooser.getSelectedFile();
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        paso1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        paso2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel4 = new javax.swing.JLabel();
        jRadioButtonCliente = new javax.swing.JRadioButton();
        jRadioButtonServidor = new javax.swing.JRadioButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        paso3C = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextPane2 = new javax.swing.JTextPane();
        jTextFieldIPServidor = new javax.swing.JTextField();
        jTextFieldSocket = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        paso3S = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel17 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextPane3 = new javax.swing.JTextPane();
        jTextFieldSocket2 = new javax.swing.JTextField();
        jTextFieldUsuario = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jTextFieldHost = new javax.swing.JTextField();
        jTextFieldPuerto = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jPasswordField = new javax.swing.JPasswordField();
        jButtonTest = new javax.swing.JButton();
        jLabelTest = new javax.swing.JLabel();
        paso4 = new javax.swing.JPanel();
        jLabel23 = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        jLabel24 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextPane4 = new javax.swing.JTextPane();
        jTextFieldRuta = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        paso5 = new javax.swing.JPanel();
        jLabel26 = new javax.swing.JLabel();
        jSeparator5 = new javax.swing.JSeparator();
        jLabel27 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTextPane5 = new javax.swing.JTextPane();
        jProgressBar = new javax.swing.JProgressBar();
        jLabelEvento = new javax.swing.JLabel();
        pasoFinal = new javax.swing.JPanel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jButtonSiguiente = new javax.swing.JButton();
        jButtonAnterior = new javax.swing.JButton();
        jButtonCancelar = new javax.swing.JButton();
        marco = new javax.swing.JPanel();
        separador = new javax.swing.JSeparator();

        paso1.setBackground(new java.awt.Color(255, 255, 255));
        paso1.setAlignmentX(0.0F);
        paso1.setAlignmentY(0.0F);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/top.png"))); // NOI18N

        jLabel2.setFont(new java.awt.Font("Dialog", 0, 18));
        jLabel2.setForeground(new java.awt.Color(255, 102, 0));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel2.setText("Bienvenido al Instalador del");

        jLabel5.setFont(new java.awt.Font("Dialog", 0, 18));
        jLabel5.setForeground(new java.awt.Color(255, 102, 0));
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel5.setText("Sistema para Gestion de Pedidos Tu Lunch");

        jLabel6.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel6.setText("Si desea continuar, el instalador procedera a llevar a cabo la instalacion de la aplicacion en");

        jLabel7.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel7.setText("su equipo. Usted prodra definir el tipo de Instalacion ( Cliente , Servidor ) y los parametros");

        jLabel8.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel8.setText("que cada uno de estos requiera tras una serie de preguntas.");

        jLabel9.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel9.setText("Gracias , ");

        jLabel10.setFont(new java.awt.Font("Dialog", 0, 18));
        jLabel10.setForeground(new java.awt.Color(255, 102, 0));
        jLabel10.setText("Developer Dream Team");

        jLabel11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/TuLunch.jpg"))); // NOI18N

        javax.swing.GroupLayout paso1Layout = new javax.swing.GroupLayout(paso1);
        paso1.setLayout(paso1Layout);
        paso1Layout.setHorizontalGroup(
            paso1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1)
            .addGroup(paso1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(paso1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING))
                .addGroup(paso1Layout.createSequentialGroup()
                    .addComponent(jLabel11)
                    .addGap(32, 32, 32)
                    .addGroup(paso1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel5)
                        .addComponent(jLabel2))))
            .addGroup(paso1Layout.createSequentialGroup()
                .addGap(117, 117, 117)
                .addComponent(jLabel10))
        );

        paso1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2, jLabel5});

        paso1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel6, jLabel7, jLabel8, jLabel9});

        paso1Layout.setVerticalGroup(
            paso1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paso1Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGroup(paso1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(paso1Layout.createSequentialGroup()
                        .addGap(0, 0, 0)
                        .addComponent(jLabel11))
                    .addGroup(paso1Layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addGap(5, 5, 5)
                .addComponent(jLabel7)
                .addGap(5, 5, 5)
                .addComponent(jLabel8)
                .addGap(5, 5, 5)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addGap(45, 45, 45))
        );

        paso1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel2, jLabel5});

        paso1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel6, jLabel7, jLabel8, jLabel9});

        paso2.setBackground(new java.awt.Color(255, 255, 255));
        paso2.setAlignmentX(0.0F);
        paso2.setAlignmentY(0.0F);
        paso2.setMaximumSize(new java.awt.Dimension(586, 387));

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/top2.png"))); // NOI18N

        jLabel4.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel4.setText("Seleccione el Tipo de Instalacion que desea realizar : ");

        jRadioButtonCliente.setFont(new java.awt.Font("Dialog", 0, 12));
        jRadioButtonCliente.setSelected(true);
        jRadioButtonCliente.setText("Instalacion del  Cliente.");
        jRadioButtonCliente.setOpaque(false);
        jRadioButtonCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonClienteActionPerformed(evt);
            }
        });

        jRadioButtonServidor.setFont(new java.awt.Font("Dialog", 0, 12));
        jRadioButtonServidor.setText("Instalacion del Servidor.");
        jRadioButtonServidor.setOpaque(false);
        jRadioButtonServidor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonServidorActionPerformed(evt);
            }
        });

        jTextPane1.setEditable(false);
        jTextPane1.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextPane1.setText("    \n    Seleccione si su objetivo es instalar la Interfaz de MESERO o COCINA.\n\n    Si desea instalar la Apliacion Cliente, asegurece de contar con la IP del servidor y el\n    Puerto del Socket de Comunicacion con este. Estos datos le seran consultados en el\n    transcurso de la Instalacion.");
        jScrollPane1.setViewportView(jTextPane1);

        javax.swing.GroupLayout paso2Layout = new javax.swing.GroupLayout(paso2);
        paso2.setLayout(paso2Layout);
        paso2Layout.setHorizontalGroup(
            paso2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel3)
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE)
            .addGroup(paso2Layout.createSequentialGroup()
                .addGap(212, 212, 212)
                .addGroup(paso2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jRadioButtonCliente)
                    .addComponent(jRadioButtonServidor))
                .addContainerGap(214, Short.MAX_VALUE))
            .addGroup(paso2Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(paso2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 538, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addContainerGap(26, Short.MAX_VALUE))
        );
        paso2Layout.setVerticalGroup(
            paso2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paso2Layout.createSequentialGroup()
                .addComponent(jLabel3)
                .addGap(0, 0, 0)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addGap(35, 35, 35)
                .addComponent(jRadioButtonCliente)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButtonServidor)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        paso3C.setBackground(new java.awt.Color(255, 255, 255));
        paso3C.setAlignmentX(0.0F);
        paso3C.setAlignmentY(0.0F);
        paso3C.setMaximumSize(new java.awt.Dimension(586, 387));

        jLabel12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/top2.png"))); // NOI18N

        jLabel13.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel13.setText("Ingrese los parametros Iniciales de Configuracion : ");

        jTextPane2.setEditable(false);
        jTextPane2.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextPane2.setText("\n    Por favor asegurece que los datos suministrados son los correctos.\n   \n         IP del Servidor : xxx.xxx.xxx.xxx\n         Puerto del Socket de Comunicacion : xxxxx");
        jScrollPane2.setViewportView(jTextPane2);

        jTextFieldIPServidor.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextFieldIPServidor.setText("192.168.1.1");
        jTextFieldIPServidor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldIPServidorKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldIPServidorKeyTyped(evt);
            }
        });

        jTextFieldSocket.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextFieldSocket.setText("80808");
        jTextFieldSocket.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldSocketKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldSocketKeyTyped(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel14.setLabelFor(jTextFieldIPServidor);
        jLabel14.setText("IP del Servidor : ");

        jLabel15.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel15.setLabelFor(jTextFieldSocket);
        jLabel15.setText("Puerto del Socket de Comunicacion : ");

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/iconoTeclado.png"))); // NOI18N
        jButton1.setToolTipText("Teclado en Pantalla");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout paso3CLayout = new javax.swing.GroupLayout(paso3C);
        paso3C.setLayout(paso3CLayout);
        paso3CLayout.setHorizontalGroup(
            paso3CLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel12)
            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE)
            .addGroup(paso3CLayout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addGroup(paso3CLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel15)
                    .addComponent(jLabel14))
                .addGap(4, 4, 4)
                .addGroup(paso3CLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldIPServidor, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldSocket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap(65, Short.MAX_VALUE))
            .addGroup(paso3CLayout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(paso3CLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 540, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        paso3CLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTextFieldIPServidor, jTextFieldSocket});

        paso3CLayout.setVerticalGroup(
            paso3CLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paso3CLayout.createSequentialGroup()
                .addComponent(jLabel12)
                .addGap(0, 0, 0)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel13)
                .addGap(38, 38, 38)
                .addGroup(paso3CLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(paso3CLayout.createSequentialGroup()
                        .addGroup(paso3CLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldIPServidor, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(paso3CLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldSocket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15)))
                    .addGroup(paso3CLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(7, 7, 7)))
                .addGap(34, 34, 34)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        paso3CLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jTextFieldIPServidor, jTextFieldSocket});

        paso3S.setBackground(new java.awt.Color(255, 255, 255));
        paso3S.setAlignmentX(0.0F);
        paso3S.setAlignmentY(0.0F);
        paso3S.setMaximumSize(new java.awt.Dimension(586, 387));

        jLabel16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/top2.png"))); // NOI18N

        jLabel17.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel17.setText("Ingrese los parametros Iniciales de Configuracion : ");

        jTextPane3.setEditable(false);
        jTextPane3.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextPane3.setText("    Por favor asegurece que los datos suministrados son los correctos.");
        jTextPane3.setPreferredSize(new java.awt.Dimension(507, 96));
        jScrollPane3.setViewportView(jTextPane3);

        jTextFieldSocket2.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextFieldSocket2.setText("80808");
        jTextFieldSocket2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldSocket2KeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldSocket2KeyTyped(evt);
            }
        });

        jTextFieldUsuario.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextFieldUsuario.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldUsuarioKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldUsuarioKeyTyped(evt);
            }
        });

        jLabel18.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel18.setLabelFor(jTextFieldIPServidor);
        jLabel18.setText("Puerto del Socket de Comunicacion : ");

        jLabel19.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel19.setLabelFor(jTextFieldSocket);
        jLabel19.setText("Usuario Base de Datos : ");

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/iconoTeclado.png"))); // NOI18N
        jButton2.setToolTipText("Teclado en Pantalla");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel20.setLabelFor(jTextFieldSocket);
        jLabel20.setText("Password Base de Datos : ");

        jLabel21.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel21.setLabelFor(jTextFieldSocket);
        jLabel21.setText("Nombre de Host o IP del Servidor Base de Datos : ");

        jTextFieldHost.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextFieldHost.setText("localhost");
        jTextFieldHost.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldHostKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldHostKeyTyped(evt);
            }
        });

        jTextFieldPuerto.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextFieldPuerto.setText("3306");
        jTextFieldPuerto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldPuertoKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldPuertoKeyTyped(evt);
            }
        });

        jLabel22.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel22.setLabelFor(jTextFieldSocket);
        jLabel22.setText("Puerto Servidor Base de Datos : ");

        jPasswordField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jPasswordFieldKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jPasswordFieldKeyTyped(evt);
            }
        });

        jButtonTest.setText("Probar Conexion");
        jButtonTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonTestActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout paso3SLayout = new javax.swing.GroupLayout(paso3S);
        paso3S.setLayout(paso3SLayout);
        paso3SLayout.setHorizontalGroup(
            paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel16)
            .addComponent(jSeparator3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1619, Short.MAX_VALUE)
            .addGroup(paso3SLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jLabel17)
                .addContainerGap(1223, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, paso3SLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(paso3SLayout.createSequentialGroup()
                        .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel21)
                            .addComponent(jLabel18)
                            .addComponent(jLabel19)
                            .addComponent(jLabel20)
                            .addComponent(jLabel22))
                        .addGap(4, 4, 4)
                        .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextFieldPuerto, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                            .addComponent(jTextFieldSocket2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                            .addComponent(jTextFieldHost, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                            .addGroup(paso3SLayout.createSequentialGroup()
                                .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                                    .addComponent(jPasswordField, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE))
                                .addGap(0, 0, 0))))
                    .addComponent(jButtonTest))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelTest)
                    .addComponent(jButton2))
                .addGap(1048, 1048, 1048))
            .addGroup(paso3SLayout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 540, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(1045, Short.MAX_VALUE))
        );

        paso3SLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonTest, jPasswordField, jTextFieldHost, jTextFieldPuerto, jTextFieldSocket2, jTextFieldUsuario});

        paso3SLayout.setVerticalGroup(
            paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paso3SLayout.createSequentialGroup()
                .addComponent(jLabel16)
                .addGap(0, 0, 0)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(paso3SLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel17)
                        .addGap(18, 18, 18)
                        .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel18)
                            .addComponent(jTextFieldSocket2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19))
                        .addGap(6, 6, 6)
                        .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel20)
                            .addComponent(jPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldHost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel21))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldPuerto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel22))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, paso3SLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(59, 59, 59)))
                .addGroup(paso3SLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonTest)
                    .addComponent(jLabelTest, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        paso3SLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonTest, jPasswordField, jTextFieldHost, jTextFieldPuerto, jTextFieldSocket2, jTextFieldUsuario});

        paso4.setBackground(new java.awt.Color(255, 255, 255));
        paso4.setAlignmentX(0.0F);
        paso4.setAlignmentY(0.0F);
        paso4.setMaximumSize(new java.awt.Dimension(586, 387));

        jLabel23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/top2.png"))); // NOI18N

        jLabel24.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel24.setText("Seleccione la Ruta de Instalacion : ");

        jTextPane4.setEditable(false);
        jTextPane4.setFont(new java.awt.Font("Dialog", 0, 12));
        jTextPane4.setText("\n    Por favor asegurece que los datos suministrados son los correctos.\n   \n         Seleccione el Directorio en el cual se Instalara la Aplicacion.\n         Recuerde que se creara una Carpeta nueva en la ruta seleccionada.");
        jScrollPane4.setViewportView(jTextPane4);

        jTextFieldRuta.setEditable(false);
        jTextFieldRuta.setFont(new java.awt.Font("Dialog", 0, 12));

        jLabel25.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel25.setLabelFor(jTextFieldIPServidor);
        jLabel25.setText("Directorio de Instalacion : ");

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/folder.png"))); // NOI18N
        jButton3.setToolTipText("Teclado en Pantalla");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout paso4Layout = new javax.swing.GroupLayout(paso4);
        paso4.setLayout(paso4Layout);
        paso4Layout.setHorizontalGroup(
            paso4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel23)
            .addComponent(jSeparator4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE)
            .addGroup(paso4Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(paso4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel24)
                    .addGroup(paso4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, paso4Layout.createSequentialGroup()
                            .addComponent(jLabel25)
                            .addGap(2, 2, 2)
                            .addComponent(jTextFieldRuta)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(26, 26, 26))
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 540, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        paso4Layout.setVerticalGroup(
            paso4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paso4Layout.createSequentialGroup()
                .addComponent(jLabel23)
                .addGap(0, 0, 0)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(paso4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(paso4Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel24)
                        .addGap(46, 46, 46)
                        .addGroup(paso4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel25)
                            .addComponent(jTextFieldRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(paso4Layout.createSequentialGroup()
                        .addGap(68, 68, 68)
                        .addComponent(jButton3)))
                .addGap(51, 51, 51)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        paso5.setBackground(new java.awt.Color(255, 255, 255));
        paso5.setAlignmentX(0.0F);
        paso5.setAlignmentY(0.0F);
        paso5.setMaximumSize(new java.awt.Dimension(586, 387));

        jLabel26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/top2.png"))); // NOI18N

        jLabel27.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel27.setText("Progreso de la Instalacion : ");

        jTextPane5.setEditable(false);
        jTextPane5.setFont(new java.awt.Font("Dialog", 0, 12));
        jScrollPane5.setViewportView(jTextPane5);

        jProgressBar.setValue(50);
        jProgressBar.setString("100%");
        jProgressBar.setStringPainted(true);

        jLabelEvento.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabelEvento.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelEvento.setText("evento");

        javax.swing.GroupLayout paso5Layout = new javax.swing.GroupLayout(paso5);
        paso5.setLayout(paso5Layout);
        paso5Layout.setHorizontalGroup(
            paso5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel26)
            .addComponent(jSeparator5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE)
            .addGroup(paso5Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(paso5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 540, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel27))
                .addContainerGap(24, Short.MAX_VALUE))
            .addGroup(paso5Layout.createSequentialGroup()
                .addGap(77, 77, 77)
                .addGroup(paso5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelEvento, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
                    .addComponent(jProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(75, Short.MAX_VALUE))
        );
        paso5Layout.setVerticalGroup(
            paso5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paso5Layout.createSequentialGroup()
                .addComponent(jLabel26)
                .addGap(0, 0, 0)
                .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel27)
                .addGap(18, 18, 18)
                .addComponent(jLabelEvento, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
        );

        pasoFinal.setBackground(new java.awt.Color(255, 255, 255));
        pasoFinal.setAlignmentX(0.0F);
        pasoFinal.setAlignmentY(0.0F);

        jLabel29.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/top.png"))); // NOI18N

        jLabel30.setFont(new java.awt.Font("Dialog", 0, 18));
        jLabel30.setForeground(new java.awt.Color(255, 102, 0));
        jLabel30.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel30.setText("Gracias,");

        jLabel36.setFont(new java.awt.Font("Dialog", 0, 18));
        jLabel36.setForeground(new java.awt.Color(255, 102, 0));
        jLabel36.setText("Developer Dream Team");

        jLabel37.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalador/TuLunch.jpg"))); // NOI18N

        javax.swing.GroupLayout pasoFinalLayout = new javax.swing.GroupLayout(pasoFinal);
        pasoFinal.setLayout(pasoFinalLayout);
        pasoFinalLayout.setHorizontalGroup(
            pasoFinalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel29)
            .addGroup(pasoFinalLayout.createSequentialGroup()
                .addComponent(jLabel37)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 197, Short.MAX_VALUE)
                .addGroup(pasoFinalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel30)
                    .addComponent(jLabel36))
                .addGap(28, 28, 28))
        );
        pasoFinalLayout.setVerticalGroup(
            pasoFinalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pasoFinalLayout.createSequentialGroup()
                .addComponent(jLabel29)
                .addGroup(pasoFinalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pasoFinalLayout.createSequentialGroup()
                        .addGap(0, 0, 0)
                        .addComponent(jLabel37))
                    .addGroup(pasoFinalLayout.createSequentialGroup()
                        .addGap(84, 84, 84)
                        .addComponent(jLabel30)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel36)))
                .addGap(84, 84, 84))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/instalador/logo.png")).getImage());
        setResizable(false);

        jButtonSiguiente.setMnemonic('S');
        jButtonSiguiente.setText("Siguiente >");
        jButtonSiguiente.setToolTipText("Siguiente");
        jButtonSiguiente.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonSiguiente.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonSiguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSiguienteActionPerformed(evt);
            }
        });

        jButtonAnterior.setMnemonic('A');
        jButtonAnterior.setText("< Anterior");
        jButtonAnterior.setToolTipText("Anterior");
        jButtonAnterior.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonAnterior.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAnteriorActionPerformed(evt);
            }
        });

        jButtonCancelar.setMnemonic('C');
        jButtonCancelar.setText("Cancelar");
        jButtonCancelar.setToolTipText("Cancelar");
        jButtonCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarActionPerformed(evt);
            }
        });

        marco.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        marco.setAlignmentX(0.0F);
        marco.setAlignmentY(0.0F);

        javax.swing.GroupLayout marcoLayout = new javax.swing.GroupLayout(marco);
        marco.setLayout(marcoLayout);
        marcoLayout.setHorizontalGroup(
            marcoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 586, Short.MAX_VALUE)
        );
        marcoLayout.setVerticalGroup(
            marcoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 387, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(separador, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
                    .addComponent(marco, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(0, 0, 0))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(260, 260, 260)
                .addComponent(jButtonAnterior)
                .addGap(5, 5, 5)
                .addComponent(jButtonSiguiente)
                .addGap(5, 5, 5)
                .addComponent(jButtonCancelar)
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonAnterior, jButtonCancelar, jButtonSiguiente});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(marco, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, 0)
                .addComponent(separador, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(3, 3, 3)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonAnterior)
                    .addComponent(jButtonSiguiente)
                    .addComponent(jButtonCancelar))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonAnterior, jButtonCancelar, jButtonSiguiente});

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-600)/2, (screenSize.height-470)/2, 600, 470);
    }// </editor-fold>//GEN-END:initComponents
    private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarActionPerformed
        if (!termino) {
            cerrar();
        } else {
            System.exit(0);
        }
    }//GEN-LAST:event_jButtonCancelarActionPerformed

    private void jButtonSiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSiguienteActionPerformed
        VariablesDeEntorno.PASOACTUAL++;
        cambiarPanel();//GEN-LAST:event_jButtonSiguienteActionPerformed
    }

    private void jButtonAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAnteriorActionPerformed
        VariablesDeEntorno.PASOACTUAL--;
        jButtonSiguiente.setEnabled(true);
        cambiarPanel();
    }//GEN-LAST:event_jButtonAnteriorActionPerformed

    private void jRadioButtonClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonClienteActionPerformed
        VariablesDeEntorno.TIPOINSTALACION = "CLIENTE";
        jRadioButtonServidor.setSelected(false);
        jRadioButtonCliente.setSelected(true);
        jTextPane1.setText("    \n    Seleccione si su objetivo es instalar la Interfaz de MESERO o COCINA.\n\n    Si desea instalar la Apliacion Cliente, asegurece de contar con la IP del servidor y el\n    Puerto del Socket de Comunicacion con este. Estos datos le seran consultados en el\n    transcurso de la Instalacion.");
    }//GEN-LAST:event_jRadioButtonClienteActionPerformed

    private void jRadioButtonServidorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonServidorActionPerformed
        VariablesDeEntorno.TIPOINSTALACION = "SERVIDOR";
        jRadioButtonCliente.setSelected(false);
        jRadioButtonServidor.setSelected(true);
        jTextPane1.setText("    \n    Seleccione si su objetivo es instalar la Interfaz de ADMINISTRADOR o CAJERO.\n\n    Si desea instalar la Apliacion Servidor, asegurece de contar con la IP de su Equipo,\n    el Servidor de Bases de Datos MySQL ejecutandose , el usuario con privilegios y su\n    password. Estos datos le seran consultados en el transcurso de la Instalacion.");
    }//GEN-LAST:event_jRadioButtonServidorActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        jTextFieldIPServidor.requestFocus();
        TecladoEnPantalla.mostrar();        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTextFieldSocketKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldSocketKeyTyped
        char caracter = evt.getKeyChar();
        if (jTextFieldSocket.getText().length() >= 5) {
            evt.consume();
        } else {
            if ((caracter >= '0') && (caracter <= '9')) {
                VariablesDeEntorno.PUERTO = jTextFieldSocket.getText();
            } else {
                evt.consume();
            }

        }
    }//GEN-LAST:event_jTextFieldSocketKeyTyped

    private void jTextFieldIPServidorKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldIPServidorKeyTyped
        char caracter = evt.getKeyChar();
        if (jTextFieldIPServidor.getText().length() >= 15) {
            evt.consume();
        } else {
            if (((caracter >= '0') && (caracter <= '9')) || caracter == '.') {
                VariablesDeEntorno.IPSERVIDOR = jTextFieldIPServidor.getText();
            } else {
                evt.consume();
            }

        }
        
    }//GEN-LAST:event_jTextFieldIPServidorKeyTyped

    private void jTextFieldSocket2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldSocket2KeyTyped
        char caracter = evt.getKeyChar();
        if (jTextFieldSocket2.getText().length() >= 5) {
            evt.consume();
        } else {
            if ((caracter >= '0') && (caracter <= '9')) {
                VariablesDeEntorno.PUERTO = jTextFieldSocket2.getText();
            } else {
                evt.consume();
            }

        }
    }//GEN-LAST:event_jTextFieldSocket2KeyTyped

    private void jTextFieldUsuarioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldUsuarioKeyTyped
        char caracter = evt.getKeyChar();
        if (jTextFieldUsuario.getText().length() >= 255) {
            evt.consume();
        } else {
            if (Character.isSpaceChar(caracter)) {
                evt.consume();
            } else {
                VariablesDeEntorno.USUARIO = jTextFieldUsuario.getText();
            }

        }
        jLabelTest.setIcon(new ImageIcon());
    }//GEN-LAST:event_jTextFieldUsuarioKeyTyped

    private void jTextFieldHostKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldHostKeyTyped
        char caracter = evt.getKeyChar();
        if (jTextFieldHost.getText().length() >= 255) {
            evt.consume();
        } else {
            if (Character.isSpaceChar(caracter)) {
                evt.consume();
            } else {
                VariablesDeEntorno.HOST = jTextFieldHost.getText();
            }

        }
        jLabelTest.setIcon(new ImageIcon());
    }//GEN-LAST:event_jTextFieldHostKeyTyped

    private void jTextFieldPuertoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldPuertoKeyTyped
        char caracter = evt.getKeyChar();
        if (jTextFieldPuerto.getText().length() >= 4) {
            evt.consume();
        } else {
            if ((caracter >= '0') && (caracter <= '9')) {
                VariablesDeEntorno.PUERTOSERVIDOR = jTextFieldPuerto.getText();
            } else {
                evt.consume();
            }

        }
        jLabelTest.setIcon(new ImageIcon());
    }//GEN-LAST:event_jTextFieldPuertoKeyTyped

    private void jPasswordFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPasswordFieldKeyReleased
        VariablesDeEntorno.PASSWORD = new String(jPasswordField.getPassword());
        continuarServidor();
    }//GEN-LAST:event_jPasswordFieldKeyReleased

    private void jTextFieldIPServidorKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldIPServidorKeyReleased
        VariablesDeEntorno.IPSERVIDOR = jTextFieldIPServidor.getText();
        if (jTextFieldIPServidor.getText().isEmpty() || jTextFieldSocket.getText().isEmpty()) {
            jButtonSiguiente.setEnabled(false);
        } else {
            jButtonSiguiente.setEnabled(true);
        }
    }//GEN-LAST:event_jTextFieldIPServidorKeyReleased

    private void jTextFieldSocketKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldSocketKeyReleased
        VariablesDeEntorno.PUERTO = jTextFieldSocket.getText();
        if (jTextFieldIPServidor.getText().isEmpty() || jTextFieldSocket.getText().isEmpty()) {
            jButtonSiguiente.setEnabled(false);
        } else {
            jButtonSiguiente.setEnabled(true);
        }
    }//GEN-LAST:event_jTextFieldSocketKeyReleased

    private void jTextFieldSocket2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldSocket2KeyReleased
        VariablesDeEntorno.PUERTO = jTextFieldSocket2.getText();
        continuarServidor();
    }//GEN-LAST:event_jTextFieldSocket2KeyReleased

    private void jTextFieldUsuarioKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldUsuarioKeyReleased
        VariablesDeEntorno.USUARIO = jTextFieldUsuario.getText();
        continuarServidor();
    }//GEN-LAST:event_jTextFieldUsuarioKeyReleased

    private void jPasswordFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPasswordFieldKeyTyped
        if (Character.isSpaceChar(evt.getKeyChar())) {
            evt.consume();
        }
        jLabelTest.setIcon(new ImageIcon());
    }//GEN-LAST:event_jPasswordFieldKeyTyped

    private void jTextFieldHostKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldHostKeyReleased
        VariablesDeEntorno.HOST = jTextFieldHost.getText();
        continuarServidor();
    }//GEN-LAST:event_jTextFieldHostKeyReleased

    private void jTextFieldPuertoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldPuertoKeyReleased
        VariablesDeEntorno.PUERTOSERVIDOR = jTextFieldPuerto.getText();
        continuarServidor();
    }//GEN-LAST:event_jTextFieldPuertoKeyReleased

    private void jButtonTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTestActionPerformed
        VariablesDeEntorno.CONEXION = new ConexionMySQL();
        if (VariablesDeEntorno.CONEXION.testConnection()) {
            jLabelTest.setIcon(new ImageIcon(getClass().getResource("/instalador/iconoNuevo.png")));
        } else {
            jLabelTest.setIcon(new ImageIcon(getClass().getResource("/instalador/iconoBorrar.png")));
        }
    }//GEN-LAST:event_jButtonTestActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        jTextFieldSocket2.requestFocus();
        TecladoEnPantalla.mostrar(); 
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        File directorioSalida = getDirectorioSalida(jTextFieldRuta.getText());
        if (directorioSalida != null) {
            VariablesDeEntorno.RUTA = directorioSalida.getAbsolutePath();
            if (directorioSalida.isAbsolute()) {
                VariablesDeEntorno.RUTA += VariablesDeEntorno.SEPARADOR;
            }
            if (VariablesDeEntorno.TIPOINSTALACION.equals("CLIENTE")) {
                rutaCliente = VariablesDeEntorno.RUTA + "TuLunch" + VariablesDeEntorno.SEPARADOR + "Cliente";
                jTextFieldRuta.setText(rutaCliente);
            } else {
                rutaServidor = VariablesDeEntorno.RUTA + "TuLunch" + VariablesDeEntorno.SEPARADOR + "Servidor";
                jTextFieldRuta.setText(rutaServidor);
            }
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                new VentanaInstalador().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButtonAnterior;
    private javax.swing.JButton jButtonCancelar;
    private javax.swing.JButton jButtonSiguiente;
    private javax.swing.JButton jButtonTest;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    public static javax.swing.JLabel jLabelEvento;
    private javax.swing.JLabel jLabelTest;
    private javax.swing.JPasswordField jPasswordField;
    public static javax.swing.JProgressBar jProgressBar;
    private javax.swing.JRadioButton jRadioButtonCliente;
    private javax.swing.JRadioButton jRadioButtonServidor;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JTextField jTextFieldHost;
    private javax.swing.JTextField jTextFieldIPServidor;
    private javax.swing.JTextField jTextFieldPuerto;
    private javax.swing.JTextField jTextFieldRuta;
    private javax.swing.JTextField jTextFieldSocket;
    private javax.swing.JTextField jTextFieldSocket2;
    private javax.swing.JTextField jTextFieldUsuario;
    private javax.swing.JTextPane jTextPane1;
    private javax.swing.JTextPane jTextPane2;
    private javax.swing.JTextPane jTextPane3;
    private javax.swing.JTextPane jTextPane4;
    public static javax.swing.JTextPane jTextPane5;
    private javax.swing.JPanel marco;
    private javax.swing.JPanel paso1;
    private javax.swing.JPanel paso2;
    private javax.swing.JPanel paso3C;
    private javax.swing.JPanel paso3S;
    private javax.swing.JPanel paso4;
    private javax.swing.JPanel paso5;
    private javax.swing.JPanel pasoFinal;
    private javax.swing.JSeparator separador;
    // End of variables declaration//GEN-END:variables
}
